package 动态中位数;

import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        PriorityQueue<Integer> up = new PriorityQueue<>();
        PriorityQueue<Integer> down = new PriorityQueue<>((x, y) -> {
            return y - x;
        });
        while (T-- > 0) {
            up.clear();
            down.clear();
            int id = in.nextInt();
            int n = in.nextInt();
            System.out.println(id + " " + (n + 1) / 2);
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                int x = in.nextInt();
                if (down.isEmpty() || x <= down.peek()) {
                    down.offer(x);
                } else {
                    up.offer(x);
                }
                if (down.size() > up.size() + 1) {
                    up.offer(down.poll());
                }
                if (up.size() > down.size()) {
                    down.offer(up.poll());
                }
                if (i % 2 == 0) {
                    System.out.print(down.peek() + " ");
                    if (++cnt % 10 == 0) {
                        System.out.println();
                    }
                }
            }
            if (cnt % 10 != 0) {
                System.out.println();
            }
        }
    }
}
